Von: Wilgorix [Wilgorix@gmx.net]
Gesendet: Donnerstag, 18. Dezember 2008 03:04
An: 243yg3720@ursbeeli.ch
Betreff: [PATCH] GuildGreet Chat Hook

Hallo Urs,

ich war so frei und habe bei GuildGreet den Chat-Hook auf den Stand der
3.0 API gebracht.

Hier ist der Patch, falls Du ein neues Release herausbringen willst.

Gru, :)

Wilgorix (Olaf)


--- GuildGreet/GuildGreet.lua.orig	2008-10-19 11:27:22.000000000 +0200
+++ GuildGreet/GuildGreet.lua	2008-12-18 02:19:03.000000000 +0100
@@ -218,8 +218,9 @@ function GLDG_OnEvent(self, event, arg1,
 		GLDG_RegisterUrbinAddon(GLDG_NAME, GLDG_About)

 		GLDG_Main:UnregisterEvent("ADDON_LOADED")

 

-		GLDG_originalChatEventHandler = ChatFrame_OnEvent

-		ChatFrame_OnEvent = GLDG_ChatOnEvent

+		-- removed obsolete chat hook:
+		-- GLDG_originalChatEventHandler = ChatFrame_OnEvent

+		-- ChatFrame_OnEvent = GLDG_ChatOnEvent

 

 	elseif (event == "VARIABLES_LOADED") then

 		GLDG_Main:UnregisterEvent("VARIABLES_LOADED")

@@ -243,6 +244,15 @@ function GLDG_OnEvent(self, event, arg1,
 		GLDG_Main:RegisterEvent("CHAT_MSG_ADDON")

 		GLDG_Main:RegisterEvent("PARTY_MEMBERS_CHANGED")

 		GLDG_Main:RegisterEvent("RAID_ROSTER_UPDATE")

+		--GLDG_Print("Initializing filters:", true)

+		--GLDG_Print("CHAT_MSG_GUILD", true)

+		ChatFrame_AddMessageEventFilter("CHAT_MSG_GUILD", GLDG_ChatFilter)

+		--GLDG_Print("CHAT_MSG_OFFICER", true)

+		ChatFrame_AddMessageEventFilter("CHAT_MSG_OFFICER", GLDG_ChatFilter)

+		--GLDG_Print("CHAT_MSG_CHANNEL", true)

+		ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", GLDG_ChatFilter)

+		--GLDG_Print("CHAT_MSG_WHISPER", true)

+		ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", GLDG_ChatFilter)

 

 	elseif (event == "GUILD_ROSTER_UPDATE") then

 		if IsInGuild() then

@@ -5953,13 +5963,17 @@ classColors["ROGUE"]	= "|cFFFFF569";
 classColors["HUNTER"]	= "|cFFAAD473";

 

 ------------------------------------------------------------

-function GLDG_ChatOnEvent(self, event, ...)

+--function GLDG_ChatOnEvent(self, event, ...)

+function GLDG_ChatFilter(msg)

 --[[

 	taken from "http://www.wowwiki.com/Events_C_(Cancel,_Character,_Chat,_Cinematic,_Clear,_Close,_Confirm,_Corpse,_Craft,_Current,_Cursor,_CVar)"

+	and from "http://www.wowwiki.com/API_ChatFrame_AddMessageEventFilter"

+

+	parameters, except for the message, are now passed in globals (from 2.4 on, even in 3.0)

 

 	"CHAT_MSG_CHANNEL"

 	Called when the client recieves a channel message.

-	arg1: chat message

+	msg:  chat message (was in: arg1)

 	arg2: author

 	arg3: language

 	arg4: channel name with number

@@ -5971,28 +5985,28 @@ function GLDG_ChatOnEvent(self, event, .
 

 	"CHAT_MSG_GUILD"

 	Fired when a message is sent or received in the Guild channel.

-	arg1: Message that was sent

+	msg:  Message that was sent (was in: arg1)

 	arg2: Author

 	arg3: Language that the message was sent in

 

 	"CHAT_MSG_OFFICER"

 	Fired when a message is sent or received in the Guild Officer channel.

-	arg1: Message that was received

+	msg:  Message that was received (was in: arg1)

 	arg2: Author

 	arg3: Language used

 

 	"CHAT_MSG_WHISPER"

 	Fired when a whisper is received from another player.

 	The rest of the arguments appear to be nil

-	arg1: Message received

+	msg:  Message received (was in: arg1)

 	arg2: Author

 	arg3: Language (or nil if universal, like messages from GM)

 	arg6: status (like "DND" or "GM")

 ]]

 

-	local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11 = ...;

+	-- local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11 = ...;

 

-	--GLDG_Print("CHAT: event ["..tostring(event).."] - arg1 ["..tostring(arg1).."] - arg2 ["..tostring(arg2).."] - arg3 ["..tostring(arg3).."]");

+	--GLDG_Print("CHAT: event ["..tostring(event).."] - msg ["..tostring(msg).."] - arg2 ["..tostring(arg2).."] - arg3 ["..tostring(arg3).."]");

 

 	if GLDG_Data.ExtendChat then

 		local main = ""

@@ -6082,18 +6096,19 @@ function GLDG_ChatOnEvent(self, event, .
 			end

 		end

 

-		if ((main ~= "") and arg1 and arg2 and (arg2 ~= GLDG_Player)) then

-			arg1 = GLDG_Data.colours.help.."{"..main.."}|r "..arg1

+		if ((main ~= "") and msg and arg2 and (arg2 ~= GLDG_Player)) then

+			msg = GLDG_Data.colours.help.."{"..main.."}|r "..msg

 		end

 

 		--if (treated) then

-			--GLDG_Print("Main of ["..tostring(arg2).."] is ["..tostring(main).."] - passed text is ["..tostring(arg1).."]");

+			--GLDG_Print("Main of ["..tostring(arg2).."] is ["..tostring(main).."] - passed text is ["..tostring(msg).."]");

 		--end

 	end

 

-	if (self and event) then

-		GLDG_originalChatEventHandler(self, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11)

-	end

+	--if (event) then

+	--	GLDG_originalChatEventHandler(self, event, msg, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11)

+	--end

+	return false, msg

 end

 

 --------------------------


-- 
Wilgorix (Wilgorix <at> gmx.net)
Die silberne Hand
